<template>
  <el-breadcrumb class="ele-breadcrumb">
    <el-breadcrumb-item
      v-for="item in list"
      :key="item.path"
    >
      <router-link :to="item.path">
        {{ item.meta.title }}
      </router-link>
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script setup lang="ts">
import { computed, defineProps } from 'vue'
import { useRoute } from 'vue-router'
import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
import { findRouterItemListByPath } from '../utils/index'
import { useCurrentRoutes } from '../composables/index'
import type { IRouteRecordRaw } from '../types/index'

const props = defineProps<{ routes?: IRouteRecordRaw[] }>()
const route = useRoute()
const routes = useCurrentRoutes(props)
const list = computed(() => {
  return findRouterItemListByPath(routes.value, route.path)
})
</script>
<style>
.ele-breadcrumb .el-breadcrumb__inner a {
  color: #999 !important;
  font-weight: 500 !important;
  font-size: 13.6px;
  text-decoration: none !important;
}
.ele-breadcrumb .el-breadcrumb__separator {
  font-size: 10px !important;
  color: #999 !important;
  font-weight: 500 !important;
}
.ele-breadcrumb .el-breadcrumb__inner .router-link-exact-active {
  color: #515a6e !important;
}
</style>
